package org.xx.Iterator;

import java.util.ArrayList;
import java.util.List;

public class IteratorMain {
    public static void main(String[] args) {
        List<Book> bookArrayList = new ArrayList<>();
        BookShelf bookShelf = new BookShelf(bookArrayList);
        bookShelf.appendBook(new Book("A"));
        bookShelf.appendBook(new Book("B"));
        bookShelf.appendBook(new Book("C"));
        bookShelf.appendBook(new Book("D"));

        Iterator iterator = bookShelf.iterator();
        while (iterator.hasNext()) {
            Book book = (Book) iterator.next();
            System.out.println(book.getName());
        }


        List<Student> studentList = new ArrayList<>();
        StudentClass studentClass = new StudentClass(studentList);
        studentClass.add(new Student("x1",24));
        studentClass.add(new Student("x2",25));
        studentClass.add(new Student("x3",26));
        studentClass.add(new Student("x4",27));

        Iterator iterator1 = studentClass.iterator();
        while (iterator1.hasNext()) {
            Student student = (Student) iterator1.next();
            System.out.println(student.toString());
        }
    }
}
